package com.zlzf.helloworld.popupwindow;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Gravity;
import android.view.View;

import com.zlzf.helloworld.R;

public class PopupWindowActivity extends AppCompatActivity {

    //自定义的弹出框类
    SelectPicPopupWindow menuWindow;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_popup_window);
    }

    public void popup(View view) {

//实例化SelectPicPopupWindow
        menuWindow = new SelectPicPopupWindow(PopupWindowActivity.this, itemsOnClick);
        //显示窗口
        menuWindow.showAtLocation(PopupWindowActivity.this.findViewById(R.id.activity_popup_window), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0);
        //设置layout在PopupWindow中显示的位置
    }


    //为弹出窗口实现监听类
    private View.OnClickListener itemsOnClick = new View.OnClickListener(){

        public void onClick(View v) {
            menuWindow.dismiss();
            switch (v.getId()) {
                case R.id.btn_take_photo:

                    break;
                case R.id.btn_pick_photo:
                    break;
                default:
                    break;
            }


        }

    };

}
